import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {AdminComponent} from './admin.component';
import {SharedModule} from '../shared/shared.module';
import {Ng2SmartTableModule} from 'ng2-smart-table';
import {NbDialogModule} from '@nebular/theme';
import {NgxEchartsModule} from 'ngx-echarts';

import {RouterModule, Routes} from '@angular/router';
import {ThemeModule} from '../@theme/theme.module';
import {TokenInterceptor} from '../token.interceptor';
import {AuthGuard} from '../auth.guard';
import {HTTP_INTERCEPTORS} from '@angular/common/http';
import {DashboardComponent} from './dashboard/dashboard.component';
import {FoodComponent} from './food/food.component';
import {ButtonApprovalComponent, ManufactureComponent} from './manufacture/manufacture.component';
import {ProduceFindComponent} from './produce-find/produce-find.component';
import {CompanyComponent} from './company/company.component';
import {PeerSearchComponent} from '../shared/peer-search/peer-search.component';
import {PeerAddComponent} from '../shared/peer-add/peer-add.component';
import {ButtonViewComponent} from './food/food.component';
import { QuestionComponent } from './question/question.component';


const appRoutes: Routes = [
  {
    path: '',
    component: AdminComponent,
    children: [
      {
        path: 'dashboard',
        component: DashboardComponent
      },
      {
        path: 'food',
        component: FoodComponent,
      },
      {
        path: 'produce-find',
        component: ProduceFindComponent,
      },
      {
        path: 'manufacture',
        component: ManufactureComponent,
      },
      {
        path: 'company',
        component: CompanyComponent,
      },
      {
        path: 'peer/search',
        component: PeerSearchComponent,
      },
      {
        path: 'peer/add',
        component: PeerAddComponent,
      },
      {
        path: 'question',
        component: QuestionComponent,
      }
    ]
  }
];

@NgModule({
  declarations: [AdminComponent, DashboardComponent, FoodComponent, ManufactureComponent, ProduceFindComponent, CompanyComponent, ButtonViewComponent, ButtonApprovalComponent, QuestionComponent],
  imports: [
    CommonModule,
    ThemeModule,
    RouterModule.forChild(appRoutes),
    SharedModule,
    Ng2SmartTableModule,
    NbDialogModule.forChild(),
    NgxEchartsModule,
  ],
  providers: [
    {provide: HTTP_INTERCEPTORS, useClass: TokenInterceptor, multi: true},
    AuthGuard,
  ],
})
export class AdminModule {
}
